﻿@model GitCandy.Models.UserModel

@{
    ViewBag.Title = string.Format(SR.Shared_TitleFormat, string.Format(SR.Account_EditTitle, Model.Name));
    var token = GitCandy.Security.Token.Current;
}

<h3>@string.Format(SR.Account_EditTitle, Model.Name)</h3>


@using (Html.BeginForm("Edit", "Account", FormMethod.Post))
{
    <dl class="dl-horizontal col-md-8">
        <dt>@Html.DisplayNameFor(s => s.Name)</dt>
        <dd>
            @Html.HiddenFor(s => s.Name)
            @Model.Name
        </dd>

        <dt>@Html.DisplayNameFor(s => s.Password)</dt>
        <dd>@Html.PasswordFor(s => s.Password, new { @class = "form-control" })</dd>
        <dd>
            <span class="text-danger">
                @Html.ValidationMessageFor(s => s.Password)
            </span>
        </dd>

        <dt>@Html.DisplayNameFor(s => s.Nickname)</dt>
        <dd>@Html.TextBoxFor(s => s.Nickname, new { @class = "form-control" })</dd>
        <dd>
            <span class="text-danger">
                @Html.ValidationMessageFor(s => s.Nickname)
            </span>
        </dd>

        <dt>@Html.DisplayNameFor(s => s.Email)</dt>
        <dd>@Html.TextBoxFor(s => s.Email, new { @class = "form-control" })</dd>
        <dd>
            <span class="text-danger">
                @Html.ValidationMessageFor(s => s.Email)
            </span>
        </dd>

        <dt>@Html.DisplayNameFor(s => s.Description)</dt>
        <dd>@Html.TextAreaFor(s => s.Description, 4, 0, new { @class = "form-control" })</dd>
        <dd>
            <span class="text-danger">
                @Html.ValidationMessageFor(s => s.Description)
            </span>
        </dd>

        @if (token.IsSystemAdministrator)
        {
        <dt>@Html.DisplayNameFor(s => s.IsSystemAdministrator)</dt>
        <dd>
            <div class="switch" data-on-label="@SR.Shared_Yes" data-off-label="@SR.Shared_No">
                @Html.CheckBoxFor(s => s.IsSystemAdministrator, new { data_size = "small" })
            </div>
        </dd>
        }

        <dt></dt>
        <dd>@Html.ValidationSummary(true, SR.Account_UpdateUnsuccessfull, new { @class = "alert alert-dismissable alert-danger" })</dd>

        <dt>
            @Html.ActionLink(SR.Shared_Back, "Detail", new { Model.Name }, new { @class = "btn btn-default pull-left" })
        </dt>
        <dd>
            <button type="submit" class="btn btn-primary">@SR.Shared_Save</button> &nbsp;
            <button type="reset" class="btn btn-inverse">@SR.Shared_Reset</button> &nbsp;
            @if (token != null && token.IsSystemAdministrator)
            {
                @Html.ActionLink(SR.Shared_Delete, "Delete", new { Model.Name }, new { @class = "btn btn-danger" })
            }
        </dd>
    </dl>
}
